﻿
#region 版权声明





//



// 
// 代码开源主要用于解决大家在学习和研究协议过程中遇到由于缺乏代码所带来的制约性问题。
// 本代码仅供学习交流使用，大家在使用此开发包前请自行协调好多方面关系，
// 不得用于任何商业用途和非法用途，本人不享受和承担由此产生的任何权利以及任何法律责任。
// 
// 本源代码可通过以下网址获取:
// http://www.vckers.com
//
// Copyright @ 2009-2010  vckers.com.  All Rights Reserved.   
// Framework: 3.5

  

 
//   
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. 
  
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace TS.QQ.Packets
{
    /// <summary>
    /// 错误代码
    /// </summary>
    public enum ErrorPacketType
    {
        /// <summary>
        /// 远端已经关闭连接 
        /// </summary>
        ERROR_CONNECTION_BROKEN = 0,
        /// <summary>
        ///  操作超时
        /// </summary>
        ERROR_TIMEOUT = 1,
        /// <summary>
        /// 代理服务器错误
        /// </summary>
        ERROR_PROXY = 2,
        /// <summary>
        /// 网络错误
        /// </summary>
        ERROR_NETWORK = 3,
        /// <summary>
        /// 运行时错误，调试用
        /// </summary>
        RUNTIME_ERROR = 4
    }
    /// <summary>这个包和协议无关，它用来通知上层，有些错误发生了，上层应该检查errorCode字段
    /// 来获得更具体的信息
    /// </summary>
    public class ErrorPacket : BasicInPacket
    {
        public ProtocolFamily Family { get; set; }
        public ErrorPacketType ErrorType;
        public string ConnectionId { get; set; }
        public string ErrorMessage { get; set; }
        /// <summary>在运行时错误的异常
    /// </summary>
        /// <value></value>
        public Exception e { get; private set; }
        /// <summary>
        /// 用在超时错误中
        /// </summary>
        public OutPacket TimeOutPacket { get; set; }
        public ErrorPacket(ErrorPacketType errorType, QQClient client, Exception e)
            : this(errorType, client)
        {
            this.e = e;
        }
        /// <summary>
    /// </summary>
        /// <param name="errorType">Type of the error.</param>
        /// <param name="user">The user.</param>
        public ErrorPacket(ErrorPacketType errorType, QQClient client)
            : base(QQCommand.Unknown, client)
        {
            this.ErrorType = errorType;
            this.Family = ProtocolFamily.All;
            ErrorMessage = "";
        }
        protected override void ParseBody(ByteBuffer buf)
        {

        }
        public override ProtocolFamily GetFamily()
        {
            return this.Family;
        }
    }
}
